package com.smrs.goods.webapp.action;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.smrs.goods.model.GoodsSkuModel;

public class SearchSkuJsonAction extends GoodsSkuAction{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Long rows = 0L;
	private Long page = 0L;
	private Long total = 0L;
	private Long records = 0L;
	private String sord;
	private String sidx;
	private String order;
	public Long getRows() {
		return rows;
	}

	public void setRows(Long rows) {
		this.rows = rows;
	}
	public Long getPage() {
		return page;
	}
	public void setPage(Long page) {
		this.page = page;
	}
	public Long getTotal() {
		return total;
	}
	public void setTotal(Long total) {
		this.total = total;
	}
	public Long getRecords() {
		return records;
	}
	public void setRecords(Long records) {
		this.records = records;
	}
	public String getSord() {
		return sord;
	}
	public void setSord(String sord) {
		this.sord = sord;
	}
	public String getSidx() {
		return sidx;
	}
	public void setSidx(String sidx) {
		this.sidx = sidx;
	}
	public String getOrder() {
		return order;
	}
	public void setOrder(String order) {
		this.order = order;
	}
	public String execute() throws Exception {
		//String name = goodsSku.getName();
		getPager().setCurrentPage(page);
		getPager().setPageSize(rows);
		if(StringUtils.isNotEmpty(sidx)) {
			getPager().setOrderProperty(sidx);
			getPager().setOrder(StringUtils.defaultIfEmpty(sord, "asc"));
		}

		pager = goodsSkuService.findBySku(goodsSku, pager);
		List<GoodsSkuModel> list = pager.getRecords();
		this.buildAttributeToSku(list);
		this.setTotal(this.getPager().getTotalPages());
		this.setRecords(this.getPager().getTotalRecords());

		return SUCCESS;
	}
}
